package org.example.Business;

import org.example.DAO.studentDAO;
import org.example.Model.student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class studentService {
    studentDAO studentdao;

    @Autowired
    @Qualifier(value="studentDAOimpl")
    public void setStudentdao(studentDAO studentdao) {
        this.studentdao = studentdao;
    }
    public void insert(student student){
     studentdao.insertstu(student);
    }
    @Transactional
    public  void addSage(int num){
        List<student> studentList=studentdao.queryAll();
    for(student b:studentList){
        b.setSage(b.getSage()+num);
        studentdao.modifystu(b);
    }
    }

}
